#include "hplcqinfineparsecommonsystempacket.h"
#include "hplcqinfineprotocolcommondata.h"
#include "hplcqinfinepfcid.h"
#include "hplcqinfinepacketformat.h"

#include <QVariant>
#include "modulehplccmdid.h"

namespace hplc
{
namespace qinfine
{

HplcQinfineParseCommonSystemPacket::HplcQinfineParseCommonSystemPacket(HplcQinfineProtocolCommonData &data, hplc::CommonParam &param, QObject *parent)
    : QObject (parent)
    , m_param(&param)
{
    m_d = &data;
}

void HplcQinfineParseCommonSystemPacket::parseSet(quint8 pfc, char *data)
{
    switch (pfc)
    {
    case PFC_GES_RESET:
        break;
    case PFC_GES_RESTORE_DEFAULT:
        break;
    case PFC_GES_SAVE_AS_DEFAULT:
        break;
    case PFC_GES_SUPERPASSWORD:
    {
        QString str = QString(data);
        m_param->superPassword = str;

        QVariant var;
        var.setValue(m_param->superPassword);
        emit parseCompleted(hplc::CommonSystemCmdID_SetSuperPassword, var);
    }
        break;
    case PFC_GES_SOFTWARE_VERSION:
    {
        m_param->softwareVersion = QString(data);

        QVariant var;
        var.setValue(m_param->softwareVersion);
        emit parseCompleted(hplc::CommonSystemCmdID_SetSoftwareVersion, var);
    }
        break;
    case PFC_GES_HARDWARE_VERSION:
    {
        m_param->hardwareVersion = QString(data);

        QVariant var;
        var.setValue(m_param->hardwareVersion);
        emit parseCompleted(hplc::CommonSystemCmdID_SetHardwareVersion, var);
    }
        break;
    case PFC_GES_PRODUCT_DATE:
    {
        m_param->productDate = QString(data);

        QVariant var;
        var.setValue(m_param->productDate);
        emit parseCompleted(hplc::CommonSystemCmdID_SetProductDate, var);
    }
        break;
    case PFC_GES_SERIAL_NUMBER:
    {
        m_param->serialNumber = QString(data);

        QVariant var;
        var.setValue(m_param->productDate);
        emit parseCompleted(hplc::CommonSystemCmdID_SetSerialNumber, var);
    }
        break;
    case PFC_GES_MODEL: // 注意:型号放到子类解析
    {
        emit setModel(data[0]);

        QVariant var;
        var.setValue(data[0]);
        emit parseCompleted(hplc::CommonSystemCmdID_SetModel, var);
    }
        break;
    case PFC_GES_MODEL_STRING:
    {
        m_param->modelString = QString(data);

        QVariant var;
        var.setValue(m_param->modelString);
        emit parseCompleted(hplc::CommonSystemCmdID_SetModelString, var);
    }
        break;
    case PFC_GES_USED_TIME:
    {
        m_param->usedTime = PTR2U32(data);

        QVariant var;
        var.setValue(m_param->usedTime);
        emit parseCompleted(hplc::CommonSystemCmdID_SetUsedTime, var);
    }
        break;
    case PFC_GES_ALL_DATA:
        break;
    case PFC_GES_PROTOCOL:
    {
        m_param->protocol = (ProtocolType)(data[0]);

        QVariant var;
        var.setValue(m_param->protocol);
        emit parseCompleted(hplc::CommonSystemCmdID_SetProtocol, var);
    }
        break;
    default:
        break;
    }
}

void HplcQinfineParseCommonSystemPacket::parseGet(quint8 pfc, char *data)
{
    Q_UNUSED(data)
    switch (pfc)
    {
    case PFC_GES_RESET:
        break;
    case PFC_GES_RESTORE_DEFAULT:
        break;
    case PFC_GES_SAVE_AS_DEFAULT:
        break;
    case PFC_GES_SUPERPASSWORD:
        break;
    case PFC_GES_SOFTWARE_VERSION:
        break;
    case PFC_GES_HARDWARE_VERSION:
        break;
    case PFC_GES_PRODUCT_DATE:
        break;
    case PFC_GES_SERIAL_NUMBER:
        break;
    case PFC_GES_MODEL:
        break;
    case PFC_GES_MODEL_STRING:
        break;
    case PFC_GES_USED_TIME:
        break;
    case PFC_GES_ALL_DATA:
        break;
    case PFC_GES_PROTOCOL:
        break;
    default:
        break;
    }
}

} // qinfine
} // hplc
